/*购物车状态模块
 */
export default {
  state: {
    shoppingCart: [],
    shopcarNumber:0,
     // 存储选中的购物车数据
     buyGoodsList:[],
     // 存实付款金额
     totalPrice:'',
  },
  getters: {
    getShoppingCart (state) {
      // 获取购物车状态
      return state.shoppingCart;
    },
      // 获取购物车数量
    getShopcarNumber:(state)=>{
      return state.shopcarNumber
    },
    // 获取选中的购物车数据
    getBuyGoodsList:(state)=>{
      return state.buyGoodsList
    },
    // 存实付款金额
    getTotalPrice:(state)=>{
      return state.totalPrice
    }
  },
  mutations: {
    setShoppingCart (state, data) {
      // 设置购物车状态
      state.shoppingCart = data;
    },
    // 存购物车数量
    setShopcarNumber(state,data){
      state.shopcarNumber= data
    },
    // 存储选中的购物车数据
    setBuyGoodsList(state,data){
      state.buyGoodsList = data
    },
    // 存实付款金额
    setTotalPrice(state,data){
      state.totalPrice = data
    },
  },
  actions: {
    setShoppingCart ({ commit }, data) {
      commit('setShoppingCart', data);
    },
     // 存购物车数量
     setShopcarNumber({ commit },data){
      commit("setShopcarNumber",data)
    },
     // 存储选中的购物车数据
     setBuyGoodsList({commit},data){
       commit("setBuyGoodsList",data)
     },
     // 存实付款金额
     setTotalPrice({commit},data){
       commit("setTotalPrice",data)
     }
  }
}